<%@page import="java.util.ArrayList"%>
<%@page import="com.gua.jbs.pojo.Jbspit"%>
<%@page import="java.util.List"%>
<%@page import="com.gua.jbs.utility.ApplicationConstant"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/pages/common/header.jsp"%>
<html>
<head>
<script>
	$(function() {
		$("form").validity(function() {
			$("#name").require().match(/^[0-9a-zA-Z]+$/);
			$("#rate").require().match("number");
			$("#cost").require().match("number");
			$("#quantity").require().match("number");
			$("#hrCode").require();
			$("#numCode").require();
			$("#designCode").require().match(/^[0-9a-zA-Z]+$/);

		});
	});
</script>
</head>

<c:set var="message" value="${param.message}" />
<c:if test="${empty message}">
	<c:set var="message" value="${requestScope.message}" />
</c:if>

<body class="mainbody" onload="msgDisplay('${message}');" >
	<c:set var="prodDetails" value="${requestScope.prodDetails}" />
	<c:set var="map_prodTypes" value="${requestScope.productTypes}" />
	<c:set var="map_productSubTypes"
		value="${requestScope.productSubTypes}" />
	<c:set var="map_productColor" value="${requestScope.productColor}" />
	<c:set var="map_productPolish" value="${requestScope.productPolish}" />
	<c:set var="map_productSize" value="${requestScope.productSize}" />

	<c:forEach var="product" items="${prodDetails}" varStatus="counter">
		<c:set var="upProdId" value="${product.prodId}"></c:set>
		<c:set var="upProdName" value="${product.prodName}"></c:set>
		<c:set var="upProdType" value="${product.prodType}"></c:set>
		<c:set var="upProdCode" value="${product.prodCode}"></c:set>
		<c:set var="upProdPrice" value="${product.prodPrice}"></c:set>
		<c:set var="upProdSize" value="${product.prodSize}"></c:set>
		<c:set var="upProdColor" value="${product.prodColor}"></c:set>
		<c:set var="upProdImage" value="${product.prodImage}"></c:set>
		<c:set var="upProdWeight" value="${product.prodweight}"></c:set>
		<c:set var="upProdQuantity" value="${product.extrafield3}"></c:set>
		<c:set var="upProdPolish" value="${product.extrafield2}"></c:set>
		<c:set var="upProdAbout" value="${product.extrafield1}"></c:set>
		<c:set var="upProdSubType" value="${product.prodSubType}"></c:set>
		<c:set var="upDesignCode" value="${product.designCode}"></c:set>
		<c:set var="upHrCode" value="${product.hrCode}"></c:set>
		<c:set var="upIsApproved" value="${product.isApproved}"></c:set>
		<c:set var="upCostPrice" value="${product.prodCost}"></c:set>
	</c:forEach>

	<div class="mainContainer">
		<section class="bodyContainer">
		<div class="productReport">
			<h2 class="titleTxtBig">Product Specifications</h2>
			<p class="hrlineBr"></p>
			<form id="editProdEntryForm" method="post"
				action="${context}/productEntry" enctype="multipart/form-data">
				<c:if test="${prodDetails ne null}">
					<input type="hidden" name="ACTION" value="EP">
					<input type="hidden" name="prodId" value="${upProdId}">
				</c:if>
				<c:if test="${prodDetails eq null}">
					<input type="hidden" name="ACTION" value="AP">
					<input type="hidden" name="prodId" value="${upProdId}">
				</c:if>
				<div class="productSfcField">
					<div class="divclear">
						<span class="loginlabel">Name : </span> <span
							class="logininputFld"><input class="loginfld" id="name"
							name="productName" type="text" value="${upProdName}"> </span>
					</div>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Type : </span> <span
							class="logininputFld"> <select name="productType"
							class="loginSelectfld">

								<c:if test="${not empty fn:length(map_prodTypes)}">
									<c:forEach var="prodTypesgroup" items="${map_prodTypes}">
										<c:set var="prodTypes" value="${prodTypesgroup.key}" />
										<c:forEach var="prodTypeValue" items="${prodTypesgroup.value}">
											<c:choose>
												<c:when test="${prodTypeValue.key eq upProdType}">
													<option value="${prodTypes}" selected>${upProdType}</option>
												</c:when>
												<c:otherwise>
													<option value="${prodTypes}">${prodTypeValue.key}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
									</c:forEach>
								</c:if>

						</select> </span>
					</div>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Sub-Type : </span> <span
							class="logininputFld"> <select name="productSubType"
							class="loginSelectfld">
								<c:if test="${not empty fn:length(map_productSubTypes)}">
									<c:forEach var="prodSubTypesgroup"
										items="${map_productSubTypes}">
										<c:set var="prodSubTypes" value="${prodSubTypesgroup.key}" />
										<c:forEach var="prodSubTypeValue"
											items="${prodSubTypesgroup.value}">
											<c:choose>
												<c:when test="${prodSubTypeValue.key eq upProdSubType}">
													<option value="${prodSubTypes}" selected>${upProdSubType}</option>
												</c:when>
												<c:otherwise>
													<option value="${prodSubTypes}">${prodSubTypeValue.key}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
									</c:forEach>
								</c:if>
						</select> </span>
					</div>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Color : </span> <span
							class="logininputFld"> <select name="productColor"
							class="loginSelectfld">
								<c:if test="${not empty fn:length(map_productColor)}">
									<c:forEach var="prodColorgroup" items="${map_productColor}">
										<c:set var="prodColor" value="${prodColorgroup.key}" />
										<c:forEach var="prodColorValue"
											items="${prodColorgroup.value}">
											<c:choose>
												<c:when test="${prodColorValue.key eq upProdColor}">
													<option value="${prodColor}" selected>${upProdColor}</option>
												</c:when>
												<c:otherwise>
													<option value="${prodColor}">${prodColorValue.key}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
									</c:forEach>
								</c:if>
						</select> </span>
					</div>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Polish : </span> <span
							class="logininputFld"> <select name="productPolish"
							class="loginSelectfld">
								<c:if test="${not empty fn:length(map_productPolish)}">
									<c:forEach var="prodPolishgroup" items="${map_productPolish}">
										<c:set var="prodPolish" value="${prodPolishgroup.key}" />
										<c:forEach var="prodPolishValue"
											items="${prodPolishgroup.value}">
											<c:choose>
												<c:when test="${prodPolishValue.key eq upProdPolish}">
													<option value="${prodPolish}" selected>${upProdPolish}</option>
												</c:when>
												<c:otherwise>
													<option value="${prodPolish}">${prodPolishValue.key}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
									</c:forEach>
								</c:if>
						</select> </span>
					</div>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Rate :</span> <span class="logininputFld"><input
							class="loginfld" name="productRate" id="rate" type="text"
							value="${upProdPrice}"> </span>
					</div>

					<!-- newly added field  -->
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Cost Price :</span> <span
							class="logininputFld"><input class="loginfld"
							name="costPrice" id="cost" type="text" value="${upCostPrice}">
						</span>
					</div>
					<!-- newly added field  -->

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Quantity : </span> <span
							class="rateinputFld"><input class="ratefld"
							name="productQuantity" id="quantity" value="${upProdQuantity}"
							type="text"> </span> <span class="weightlable">Size :</span> <span
							class="rateinputFld"> <select name="productSize"
							class="weightfld">
								<c:if test="${not empty fn:length(map_productSize)}">
									<c:forEach var="prodSizegroup" items="${map_productSize}">
										<c:set var="prodSize" value="${prodSizegroup.key}" />
										<c:forEach var="prodSizeValue" items="${prodSizegroup.value}">
											<c:choose>
												<c:when test="${prodSizeValue.key eq upProdSize}">
													<option value="${prodSize}" selected>${upProdSize}</option>
												</c:when>
												<c:otherwise>
													<option value="${prodSize}">${prodSizeValue.key}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
									</c:forEach>
								</c:if>
						</select> </span>
					</div>
					<c:if test="${upHrCode ne null}">
						<p class="spacerTopTen"></p>
						<div class="divclear">
							<span class="loginlabel">HR Code:</span> <span
								class="logininputFld"><input class="loginfld"
								name="hrCode" id="hrCode" value="${upHrCode}" type="text"
								disabled="disabled"> </span>
						</div>
					</c:if>

					<c:if test="${upProdCode ne null}">
						<p class="spacerTopTen"></p>
						<div class="divclear">
							<span class="loginlabel">Numeric Barcode :</span> <span
								class="logininputFld"><input class="loginfld"
								name="numCode" id="numCode" type="text" value="${upProdCode}"
								disabled="disabled"> </span>
						</div>
					</c:if>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Design Code :</span> <span
							class="logininputFld"> <c:choose>
								<c:when test="${upDesignCode ne null}">
									<input class="loginfld" id="designCode" name="prodDesignCode"
										type="text" value="${upDesignCode}" >
						</span>
						</c:when>
						<c:otherwise>
							<input class="loginfld" id="designCode" name="prodDesignCode"
								type="text" value="${upDesignCode}">
							</span>
						</c:otherwise>
						</c:choose>
					</div>

					<p class="spacerTopTen"></p>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Photo : </span> <span
							class="logininputFld"> <input class="" type="file"
							name="productImage" size="30" value="${upProdImage}"> </span>
					</div>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">Approve : </span> <span
							class="abouttxtarea"> <c:choose>
								<c:when test="${upIsApproved eq 'Y' }">
							Yes :<input type="radio" value="Y" name="productApprove"
										checked="checked"> 
							No :<input type="radio" value="N" name="productApprove">
						</span>
						</c:when>
						<c:otherwise>
							Yes :<input type="radio" value="Y" name="productApprove"> 
							No :<input type="radio" value="N" name="productApprove" checked="checked">
						</c:otherwise>
						</c:choose>
						</span>
					</div>

					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel">About : </span> <span
							class="abouttxtarea"> <textarea class="logintxtarea"
								name="productAbout" cols="" rows="">${upProdAbout}</textarea> </span>
					</div>

					<p class="spacerTopTen"></p>
					<p class="spacerTopTen"></p>
					<p class="spacerTopTen"></p>
					<div class="divclear">
						<span class="loginlabel"></span> <span
							class="buttonSiyora button80"><a><input
								type="submit" value="Save" /> </a> </span>
						<span class="buttonSiyora button80"><a href="${context}/productEntry"> CLEAR</a></span>
						<%-- <span class="printBtn"><a href=""><img src="${imageContext}/printIcon.png"></a></span> --%>
					</div>
					<p class="spacerTopTen"></p>
					<p class="spacerTopTen"></p>
					<p class="spacerTopTen"></p>
				</div>
			</form>
		</div>
		</section>
	</div>
	<!--main container-->
	<jsp:include page="/pages/common/footer.jsp" />
</body>
</html>
